﻿using System;
using System.ServiceModel;

namespace Ayatta.Service.Category
{
    public class WinService
    {
        private ServiceHost serviceHost;

        public WinService()
        {

        }

        public void Start()
        {
            try
            {
                if (serviceHost != null)
                {
                    serviceHost.Close();
                }
                serviceHost = new ServiceHost(typeof(CategoryService));
                serviceHost.Open();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                Console.ReadLine();
            }
        }

        public void Stop()
        {
            if (serviceHost == null) return;
            serviceHost.Close();
            serviceHost = null;
        }
    }
}